/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.colecoes;

import client.entidades.Channel;
import client.entidades.User;
import java.util.ArrayList;

/**
 *
 * @author root
 */
public class ColecaoCanal {

    private ArrayList<Channel> canais = new ArrayList<Channel>();

    public synchronized void adicionarCanal(Channel Canal) {
        
        this.canais.add(Canal);
    }

    public synchronized void removerCanal(Channel Canal) {
        
        canais.remove(Canal);
    }

    public synchronized Channel getCanalPorNome(String nome) {
        for (Channel u : canais) {
            if (u.getStringName().equals(nome)) {
                return u;
            }
        }
        return null;
    }

    public synchronized void stopAll() {
        canais.clear();
    }

    public ArrayList<Channel> getCanais() {
        return this.canais;
    }

    public void rmUserFromAll(User u) {
        for (Channel c : canais) {
            c.rmUser(u);
        }
    }
}
